#include "netserver.h"
#include <pthread.h>

void* client(void* arg){
    int fd=*(int*)arg;
    char buf[10240];
    int i = 0;

    while(1){
        int size=recv(fd, buf, 10240, 0);
        if(size>0){
            printf("recv:%s\n", buf);
            memset(buf, 0, 10240);
            /*
            sprintf(buf, "fd:%d--server %d: %s", fd, i++, "bbbbb");
            sleep(1);
            send(fd, buf, strlen(buf), 0);
            memset(buf, 0, 10240);
            */
        }
    }
}

int main(){
    NetServer server(33150);

    while(1){
        int fd = server.Accept();
        pthread_t thread;
        printf("connect client:%d\n", fd);
        pthread_create(&thread, NULL, &client, &fd);
    }
    return 0;
}
